package com.yuan.java.lambda;

import org.junit.Test;

import java.util.*;

/**
 * lambda
 * Created by 袁恩光 on 2017/4/19.
 */
public class LambdaTest {

    @Test
    public void mains() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "yuaneg");
        map.put("gender", "男");
        map.put("age", "18");
        map.forEach((String K, Object V) -> {
            if (K.equals("gender")) {
                System.out.println(V);
            }
        });
        map.forEach((K, V) -> System.out.println(K + "|" + V));
        List<String> list = new ArrayList<>();
        list.add("name");
        list.add("gender");
        list.add("age");
/*        list.forEach((String value) -> {
            System.out.println(value);
        });*/
        list.forEach(value -> System.out.println(value));

        //自定义排序
        List<Integer> integers = new ArrayList<>();
        integers.add(1);
        integers.add(2);
        integers.add(9);
        Collections.sort(integers, (V1, V2) -> V1 < V2 ? 1 : -1);
        integers.forEach(V -> System.out.println(V));

    }
}
